package com.wfu.mobileplayer;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import com.alibaba.android.arouter.launcher.ARouter;
import com.wfu.module_base.app.ActivityLifecycleApplication;
import com.wfu.module_base.app.GlobalApp;
import com.wfu.module_base.utils.ActivityHelper;

public class MobilePlayerApplication extends ActivityLifecycleApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        initRouter(this);
        GlobalApp.init(this);
        registerActivityLifecycleCallbacks(this);
    }

    public static void initRouter(Application application) {
        if (BuildConfig.DEBUG) {
            ARouter.openLog();     // 打印日志
            ARouter.openDebug();   // 开启调试模式(如果在InstantRun模式下运行，必须开启调试模式！线上版本需要关闭,否则有安全风险)
        }
        ARouter.init(application);
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        ActivityHelper.getAtcManager().addActivity(activity);
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
        ActivityHelper.getAtcManager().finishActivity(activity);
    }
}
